﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HA.Data
{
    [Serializable]
    public class BCSpecConc:BCMT3DMS,ICloneable
    {
        public BCSpecConc(List<string> names):base()
        {
            this._scType = MAPSCType.SPECIFIEDCONC;


            foreach (string name in names)
            {

                MultiValue mv = new MultiValue(name);

                this._specConc.Add(mv);


            }



        }


        List<MultiValue> _specConc = new List<MultiValue>();

        public List<MultiValue> SpecConc
        {
            get { return _specConc; }

        }


        //public override void OnNPeriodsChanged()
        //{
        //    base.OnNPeriodsChanged();

        //    foreach (MultiValue item in this._specConc)
        //    {
        //        item.NPeriods = this.NPeriods;
                
        //    }

        //}




        public override void OnSpeListChanged(List<string> lst)
        {
            base.OnSpeListChanged(lst);

            //写一个算法，要保证顺序性
            this._specConc.Clear();
            foreach (string name in lst)
            {

                MultiValue mv = new MultiValue(name);

                this._specConc.Add(mv);


            }



        }




        public override void MapToMT3DMs(List<double> stressPeriods, MT3DMS.DomainLayer.MT3DMSData data, CoverageSetup setup, FeatureObject fo)
        {
            if (data == null || setup == null || fo == null)
            {
                return;
            }

            if (fo is LineFO || fo is PointFO || fo is PolygonFO)
            {
                //data.SourceSinkMixing.SpMixings.Clear();
                for (int i = 0; i < fo.LstIJK.Count; i++)
                {
                    List<string> arryStr = new List<string>();
                    List<List<double>> arrydata = new List<List<double>>();

                    for (int j = 0; j < fo.SpecConc.SpecConc.Count; j++)
                    {
                        arryStr.Add(fo.SpecConc.SpecConc[j].Name);
                        List<double> innerValues = new List<double>(stressPeriods.Count);
                        foreach (var sp in stressPeriods)
                        {
                            innerValues.Add(0);
                        }
                        this.assistMapToModFlow(stressPeriods, innerValues, fo.SpecConc.SpecConc[j].DateDatas);
                        arrydata.Add(innerValues);

                    }
                    if (!isZearo(fo.SpecConc.SpecConc))
                    {
                        HA.MT3DMS.DomainLayer.MixingItem mi = new MT3DMS.DomainLayer.MixingItem(fo.LstIJK[i].I, fo.LstIJK[i].J, fo.LstIJK[i].K, MT3DMS.DomainLayer.MixingSSType.SECCONC, data.BasicTransport.StressPeriod.Periods.Count, arryStr, arrydata);
                        data.SourceSinkMixing.SpMixings.Add(mi);
                    }

                }
            }
        }

   


        public object Clone()
        {
            BCSpecConc obj = (BCSpecConc)this.MemberwiseClone();
            obj._specConc = new List<MultiValue>();
            for (int i = 0; i < this.SpecConc.Count; i++)
            {
                obj.SpecConc.Add((MultiValue)this.SpecConc[i].Clone());
            }
            return obj;
        }
    }
}
